<template>
  <div>
    <div class="container radiusBottom">
      <div class="images">
        <div class="img">
          <img :src="styleUrls[dataJson.type][dataJson.stylesType]" />
        </div>
        <div class="buttonSetStyle" @click="alertTag">修改样式</div>
      </div>
    </div>
    <div>
      <div class="container">
        <div class="title">图片 1</div>

        <div class="line">
          <div class="left">选择图片</div>
          <div class="imgContent">
            <img
              v-if="dataJson.imgUrls[0].src"
              :src="dataJson.imgUrls[0].src"
            />
            <img v-else src="https://oss.ztwlxx.cn/default999.png" />
            <p v-if="dataJson.stylesType == 0" class="describe">
              建议尺寸：宽为750px
            </p>
            <p v-if="dataJson.stylesType == 1" class="describe">
              建议尺寸：342px*180px
            </p>
            <p v-if="dataJson.stylesType == 2" class="describe">
              建议尺寸：222px*222px
            </p>
            <p v-if="dataJson.stylesType == 3" class="describe">
              建议尺寸：340px*340px
            </p>
            <p v-if="dataJson.stylesType == 4" class="describe">
              建议尺寸：340px*380px
            </p>
            <p v-if="dataJson.stylesType == 5" class="describe">
              建议尺寸：342px*380px
            </p>
          </div>
          <div>
            <el-button class="btn" @click="showdialog(0)">
              选择图片
            </el-button>
          </div>
        </div>
        <div class="line">
          <div class="left">图片链接</div>
          <el-tooltip
            effect="dark"
            :content="dataJson.imgUrls[0].jump_name"
            placement="bottom"
          >
            <el-button @click="chooseLink(0)">
              {{ dataJson.imgUrls[0].jump_name || "选择链接" }}
            </el-button>
          </el-tooltip>
        </div>
      </div>

      <div
        v-if="[1, 2, 3, 4, 5].includes(dataJson.stylesType)"
        class="container"
      >
        <div class="title">图片 2</div>

        <div class="line ">
          <div class="left">选择图片</div>
          <div class="imgContent">
            <img
              v-if="dataJson.imgUrls[1].src"
              :src="dataJson.imgUrls[1].src"
            />
            <img v-else src="https://oss.ztwlxx.cn/default999.png" />
            <p v-if="dataJson.stylesType == 1" class="describe">
              建议尺寸：342px*180px
            </p>
            <p v-if="dataJson.stylesType == 2" class="describe">
              建议尺寸：222px*222px
            </p>
            <p v-if="dataJson.stylesType == 3" class="describe">
              建议尺寸：340px*340px
            </p>
            <p v-if="dataJson.stylesType == 4" class="describe">
              建议尺寸：342px*180px
            </p>
            <p v-if="dataJson.stylesType == 5" class="describe">
              建议尺寸：340px*180px
            </p>
          </div>
          <div>
            <el-button class="btn" @click="showdialog(1)">
              上传图片
            </el-button>
          </div>
        </div>
        <div class="line">
          <div class="left">图片链接</div>
          <el-tooltip
            effect="dark"
            :content="dataJson.imgUrls[1].jump_name"
            placement="bottom"
          >
            <el-button @click="chooseLink(1)">
              {{ dataJson.imgUrls[1].jump_name || "选择链接" }}
            </el-button>
          </el-tooltip>
        </div>
      </div>
      <div v-if="[2, 3, 4, 5].includes(dataJson.stylesType)" class="container">
        <div class="title">图片{{ 3 }}</div>

        <div class="line">
          <div class="left">选择图片</div>
          <div class="imgContent">
            <img
              v-if="dataJson.imgUrls[2].src"
              :src="dataJson.imgUrls[2].src"
            />
            <img v-else src="https://oss.ztwlxx.cn/default999.png" />
            <p v-if="dataJson.stylesType == 2" class="describe">
              建议尺寸：222px*222px
            </p>
            <p v-if="dataJson.stylesType == 3" class="describe">
              建议尺寸：340px*340px
            </p>
            <p v-if="dataJson.stylesType == 4" class="describe">
              建议尺寸：342px*180px
            </p>
            <p v-if="dataJson.stylesType == 5" class="describe">
              建议尺寸：342px*180px
            </p>
          </div>
          <div>
            <el-button class="btn" @click="showdialog(2)">
              上传图片
            </el-button>
          </div>
        </div>
        <div class="line">
          <div class="left">图片链接</div>
          <el-tooltip
            effect="dark"
            :content="dataJson.imgUrls[2].jump_name"
            placement="bottom"
          >
            <el-button @click="chooseLink(2)">
              {{ dataJson.imgUrls[2].jump_name || "选择链接" }}
            </el-button>
          </el-tooltip>
        </div>
      </div>
      <div v-if="3 == dataJson.stylesType" class="container">
        <div class="title">图片{{ 4 }}</div>

        <div class="line">
          <div class="left">选择图片</div>
          <div class="imgContent">
            <img
              v-if="dataJson.imgUrls[3].src"
              :src="dataJson.imgUrls[3].src"
            />
            <img v-else src="https://oss.ztwlxx.cn/default999.png" />
            <p class="describe">建议尺寸：340px*340px</p>
          </div>
          <div>
            <el-button class="btn" @click="showdialog(3)">
              上传图片
            </el-button>
          </div>
        </div>
        <div class="line">
          <div class="left">图片链接</div>
          <el-tooltip
            class="item"
            effect="dark"
            :content="dataJson.imgUrls[3].jump_name"
            placement="bottom"
          >
            <el-button @click="chooseLink(3)">
              {{ dataJson.imgUrls[3].jump_name || "选择链接" }}
            </el-button>
          </el-tooltip>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { styleUrls } from "../../data";
export default {
  props: {
    dataJson: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      styleUrls
    };
  },
  methods: {
    alertTag() {
      this.$emit("alertTag", true, this.dataJson.stylesType, 28);
    },
    chooseLink(index) {
      this.$emit("chooseLink", index);
    },
    showdialog(index) {
      this.$emit("showdialog", index);
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~@/assets/scss/decorate.scss";
</style>
